package com.bite.order.controller;


import com.bite.order.api.ProductApi;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.example.model.ProductInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
@Slf4j
@RestController
@RequestMapping("/feign")
public class FeignController {

    @Autowired
    private ProductApi productApi;

    @RequestMapping("/o1")
    public String p1(Integer id, String userName, HttpServletResponse response) {
        log.info("过滤器传来的参数userName:{}",userName);
        response.setStatus(502);
        return productApi.p1(id);
    }

    @RequestMapping("/o2")
    public String p2(Integer id,String name){
        return productApi.p2(id,name);
    }
    
    @RequestMapping("/o3")
    public String p3(ProductInfo productInfo){
        productInfo.setId(1);
        productInfo.setProductName("商品1");
        productInfo.setProductPrice(100);
        productInfo.setState(1);
        productInfo.setCreateTime(new Date());
        productInfo.setUpdateTime(new Date());
        return productApi.p3(productInfo);
    }
}
